import { defineStore } from 'pinia'
import { ref } from 'vue'
import type { IstoreItem, ILocalAddress } from '@/types/store'

export const useStore = defineStore('store', () => {
  const storeInfo = ref<IstoreItem>()

  const localAddressLatAndLog = ref({} as ILocalAddress)

  const changeStoreInfo = (val: IstoreItem) => {
    storeInfo.value = val
  }

  const getStoreInfo = () => {
    return storeInfo.value
  }
  const getLocalAddressLatAndLog = () => {
    return localAddressLatAndLog.value
  }
  const changeLocalAddressLatAndLog = (val: ILocalAddress) => {
    localAddressLatAndLog.value = val
  }

  return {
    storeInfo,
    changeLocalAddressLatAndLog,
    getLocalAddressLatAndLog,
    getStoreInfo,
    changeStoreInfo,
  }
})
